<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>用户投诉信息回复</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<script type="text/javascript" src="<%=basePath%>resources/common.js"></script>
  </head>
  <script type="text/javascript">
  	function formVerify() {
  		//楼栋名称
  		var buildingName = trim($("textarea[name='userComplaint.sysReply']").val()); 
  		if(buildingName == "Reply not more than 500 words"){
  			buildingName = "";
  		}
  		if(buildingName==null || $.trim(buildingName)=="") {
  			showWrongPic("textarea","userComplaint.sysReply",path);
  			$("textarea[name='userComplaint.sysReply']").select();
  			$("textarea[name='userComplaint.sysReply']").focus();
  			return false;
  		} else {
  			showRightPic("textarea","userComplaint.sysReply",path);
  			if(isQuoteIn(buildingName)){
	  			showWrongPic("textarea","userComplaint.sysReply",path);
	  			alert("The response you entered contains special characters, please re-enter！");
  				$("textarea[name='userComplaint.sysReply']").select();
  				$("textarea[name='userComplaint.sysReply']").focus();
	  			return false;
  			}
  		}
  		return true;
  	}
  	function submitForm() {
  		//表单校验
  		var verify = formVerify();
  		if(!verify) return;
  		//表单信息
  		var content = $("textarea[name='userComplaint.sysReply']").val();
  		var complaintId = $("input[name='userComplaint.complaintId']").val();
  		$.getJSON(path+"beshs/customerComplaintsActionJson!replyCustomerComplaint.do?date="+new Date(), {
  			"sysReply": content,
  			"complaintId": complaintId
  		}, function(data){
  			if(data.success) {
  				Dialog.alert("Operation success！", function() {
  					var pwin = window.dialogArguments;
  	  				pwin.parent.window.frames["c_content_content"].location = path + "beshs/customerComplaintsAction!queryForPage.do?date="+new Date();
  	  				window.close();
  				});
  			} else {
  				Dialog.alert(data.msg);
  			}
  		});
  	}
  	$(function(){
  		$("input[name='submit']").click(function(){
  			submitForm();
  		});
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="">
      		  <input name="userComplaint.complaintId" type="hidden" value="<s:property value='userComplaint.complaintId' />"/>
      		  <table width="100%" border="0" cellspacing="0" cellpadding="0">
        		<tr>
        			<th>username：</th>
          			<td><s:property value='userComplaint.loginName' /></td>
            		<th>headings：</th>
          			<td><s:property value='userComplaint.complaintTitle' /></td>
            		<th>complaintTime：</th>
          			<td><s:property value='userComplaint.complaintTimeFormat' /></td>
        		</tr>
        		<tr>
        			<th>userComplaint：</th>
          			<td colspan="5"><textarea name="userComplaint.userComplaint" cols="45" rows="3" readonly="readonly">
          				<s:property value='userComplaint.userComplaint' /></textarea></td>
            	</tr>
            	<tr>
            		<th>sysReply：</th>
          			<td colspan="5">
          				<textarea name="userComplaint.sysReply" cols="45" rows="3" onfocus="showMsg(1);" id="sysReply" onblur="showMsg(2)">Reply not more than 500 words</textarea>
          				&nbsp;<span style="color:#FF0000;">*&nbsp;</span>
          			</td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="submit" value="submit" class="s_btn" onclick="return formVerify();" />
            			<input name="reset" type="reset" value="reset" class="s_btn"/></td>
        		</tr>
      		  </table>
      		</form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
<script type="text/javascript">
function showMsg(data){
	var comp = $("#sysReply");
	if(data == 1 && comp.val() == "Reply not more than 500 words"){
		comp.val("");
	}
	if(data == 2 && comp.val() == ""){
		comp.val("Reply not more than 500 words");
	}
}
</script>
</html>
